package com.pxst.fi.controller;

import com.pxst.fi.resp.FiTransactionUsageResp;
import com.pxst.fi.resp.OverallMerchantBalanceResp;
import com.pxst.fi.service.TreasuryService;
import com.pxst.resp.ApiResp;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.ValidationException;

/**
 * @author rj
 * @create 2023-10-07-14:53
 */
@RestController
@RequestMapping("/treasury")
@Api(tags = "财务部总览接口")
public class TreasuryController {

    @Autowired
    private TreasuryService treasuryService;

    @GetMapping("/merchant")
    @ApiOperation(value = "商户可用余额查询")
    public ApiResp<OverallMerchantBalanceResp> getOverallMerchantBalance(@RequestParam(value = "币种", required = true) String currency) {
        if (StringUtils.isEmpty(currency)){
            throw new ValidationException("币种不能为空!");
        }
        return treasuryService.getOverallMerchantBalance(currency);
    }

    @GetMapping("/fi")
    @ApiOperation(value = "fi今日剩余限额查询")
    public ApiResp<FiTransactionUsageResp> getFiTransactionUsage(@RequestParam(value = "币种", required = true) String currency) {
        if (StringUtils.isEmpty(currency)){
            throw new ValidationException("币种不能为空!");
        }
        return treasuryService.getFiTransactionUsage(currency);
    }

}
